imageUploader=function(){
    this.bodule='';
    this.image_type='';
    this.init=function(module){
        this.module=module;
    }
    this.setImageUploaded = function(data,module,type) {
        var file = data.uploaded_file;
        if(file.uri) {
            switch(module){
                case 'blog':
                    $('#images').append('<img width="250" id="'+data.image_id+'" \n\
                src="'+file.filepath+'" />');
                    $('#article_image_id').append('<option selected="selected" value="'+data.image_id+'">image'+data.image_id+'</option>');
                    break;
                case 'portfolio':
                    switch(type){
                        case 'title':
                            if ( $('#title-image img').length ){
                            $('#title-image img').remove()}
                            $('#title-image').append('<img width="250" id="'+data.image_id+'" \n\
                         src="'+file.filepath+'" />');
                            $('#portfolio_title_image_id').append('<option selected="selected" value="'+data.image_id+'">image'+data.image_id+'</option>');
                            break;
                        case 'main':
                            if ( $('#main-image img').length ){
                            $('#main-image img').remove()}
                            $('#main-image').append('<img width="250" id="'+data.image_id+'" \n\
                         src="'+file.filepath+'" />');
                            $('#portfolio_main_image_id').append('<option selected="selected" value="'+data.image_id+'">image'+data.image_id+'</option>');
                            break;
                    };
                    break;
                case 'review':
                    if ( $('#image img').length ){
                            $('#image img').remove()}
                    $('#image').append('<img width="250" id="'+data.image_id+'" \n\
                src="'+file.filepath+'" />');
                    $('#review_image_id').append('<option selected="selected" value="'+data.image_id+'">image'+data.image_id+'</option>');
                    break;
            }
            
        }
        return false;
        
    };


    this.uploadImage = function(upload_input, upload_callback,module,type) {
        $(upload_input)
        .ajaxStart(function(){ })
        .ajaxComplete(function(){  });
        $.ajaxFileUpload({
            url: urls['image/ajaxUploadImage'],
            secureuri:false,
            fileElementId: $(upload_input).attr('id'),
            dataType: 'json',
            success: function (data, status) {
                if((typeof(data.errors) != 'undefined') && (data.errors != '')) {
                    console.log(data.errors);
                } else {
                    upload_callback(data,module,type);
                }
            },
            error: function (data, status, e) {
                console.log(data);
            }
        })
        return false;
    };
    
};
    